﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;

namespace WindowsServiceSmsSeries
{
    public partial class ServiceSmsSeries : ServiceBase
    {
        #region 变量

        /// <summary>
        /// 主线程
        /// </summary>
        Thread threadMain;

        /// <summary>
        /// 暂停的秒数
        /// </summary>
        static int Interval = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["Interval"]) * 1000;

        #endregion

        #region 控件事件

        //构造函数
        public ServiceSmsSeries()
        {
            InitializeComponent();
        }

        //windows服务开始
        protected override void OnStart(string[] args)
        {
            threadMain = new Thread(mainThread);
            threadMain.Start();
        }

        //windows服务结束
        protected override void OnStop()
        {
             if (threadMain != null)
            {
                threadMain.Abort();
            }
        }

        #endregion

        #region 方法

        /// <summary>
        /// 主线程 方法
        /// </summary>
        public void mainThread()
        {
            while (true)
            {
                SendMsg();

                Thread.Sleep(Interval);
            }
        }

        /// <summary>
        /// 发送消息
        /// </summary>
        private void SendMsg()
        {
            
        }

        #endregion
    }
}
